Skip to content

Remove indexed tx graph (2)#1875

Closed
evanlinjin wants to merge 2 commits intobitcoindevkit:masterfrom
evanlinjin:remove-indexed-tx-graph
Closed

Remove indexed tx graph (2)#1875
evanlinjin wants to merge 2 commits intobitcoindevkit:masterfrom
evanlinjin:remove-indexed-tx-graph

Conversation

@evanlinjin
Copy link
Copy Markdown
Member

Description

This is a temporary duplicate of #1510 so see if @ValuedMammal is happy with these changes.

  • tx_graph::ChangeSet is the nested structure.
  • tx_graph::TxChangeSet is the changeset without the indexer data.

@evanlinjin evanlinjin force-pushed the remove-indexed-tx-graph branch 2 times, most recently from a202349 to 7d8ffae Compare March 7, 2025 03:50
in favour of adding a type parameter to TxGraph.
When the second type parameter `X: Indexer` is set then TxGraph behaves
like `IndexedTxGraph` used to.

I reworked the internals of `TxGraph` as I thought things were a bit
convoluted.

- feat: allow changing the indexer on TxGraph

Co-authored: LLFourn
The serialization format of the nested structure is exactly the same as
the as the old `indexed_tx_graph::ChangeSet`. The old
`tx_graph::ChangeSet` is replaced with `tx_graph::TxChangeSet`.
@evanlinjin evanlinjin force-pushed the remove-indexed-tx-graph branch from 7d8ffae to 1c026d6 Compare March 7, 2025 04:19
Copy link
Copy Markdown
Collaborator

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK. tested locally with no issue. I had a question about when we should be calling index_changeset, and the rest are nits.

for (txid, seen_at) in update.seen_ats {
changeset.merge(self.insert_seen_at(txid, seen_at));
}
self.index_changeset(&mut changeset);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I'm not sure if this line is needed because both insert_tx and insert_txout will call index_changeset.

))
)]
#[must_use]
pub struct ChangeSet<A = (), XC = ()> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could just call this I, but either way is fine.

Suggested change
pub struct ChangeSet<A = (), XC = ()> {
pub struct ChangeSet<A = (), I = ()> {

}

/// Changes the [`Indexer`] for a `TxGraph`. **This doesn't re-index the transactions in the
/// graph**. To do that that call [`reindex`].
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// graph**. To do that that call [`reindex`].
/// graph**. To do that call [`reindex`].

}

impl<A: Ord> ChangeSet<A> {
/// The [`ChangeSet`] represents changes to a [`TxGraph`] and it's internal [`Indexer`].
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The [`ChangeSet`] represents changes to a [`TxGraph`] and it's internal [`Indexer`].
/// The [`ChangeSet`] represents changes to a [`TxGraph`] and its internal [`Indexer`].

@evanlinjin
Copy link
Copy Markdown
Member Author

Closing. Refer to #1510 (comment)

@notmandatory
Copy link
Copy Markdown
Member

Closing per comment mentioned above.

@github-project-automation github-project-automation bot moved this from Needs Review to Done in BDK Chain Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api A breaking API change module-blockchain

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants